/*
 * world.c: interface implementation
 */
#include "screen.h" 
#include "world.h"

/* initialize the world. */
void init(WORLD_STATE*ws) {
  ws->quit = false;
  ws->frames = 0;
}

/* update state, called before draw() every frame. */
void update(WORLD_STATE*ws) {

}

/* render function, called every frame. */
void draw(WORLD_STATE*ws) {
  /* first clear screen with the color */
  screen_clear(22, 22, 142, 255);
  /* render text */
  /* set text color. */
  settextcolor(222, 222, 222);
  
  /* NOTICE: the Chinese text must be encoded with UTF8 */
  settextsize(48);
  outtextxy("My World!", 20, 20);
}

/* handle keyboard events to chang state */
void keyboard_handler(WORLD_STATE*ws) {
  if (event_type(KEYDOWN)) {
    switch (event_key()) {
      case KEY_ESCAPE:
        /* quit program */
        ws->quit = true;
        break;
      case KEY_ENTER:
      case KEY_RETURN:
        /* restart the game */
        break;
    }
    if (ws->quit) return;
    switch (event_key()) {
      case KEY_UP:
      case KEY_w:
        /* up pressed */
        break;

      case KEY_DOWN:
      case KEY_s:
        /* down */
        break;

      case KEY_LEFT:
      case KEY_a:
        /* left */
        break;

      case KEY_RIGHT:
      case KEY_d:
        /* right */
        break;
      case KEY_SPACE:
        /* space key pressed */
        break;
    }
  }
}

/* handle mouse events to chang state */
void mouse_handler(WORLD_STATE*ws){
	
}
